package com.sservice.base.entity.dto;

import lombok.Data;

import java.io.Serializable;

/**
 * Created by suweiming on 2017/12/20.
 */
@Data
public class Pagination implements Serializable {
    private static final long serialVersionUID = -4185151304730685034L;
    private int page;
    private int total;
    private int size;
    private int totalPage;// 总页数

    public Pagination() {
    }

    int getTotalPage(int total, int size) {
        if (size == 0) size = 15;
        return (total / size) + ((total % size) > 0 ? 1 : 0);
    }

    public Pagination(int page, int total, int size) {
        this.page = page;
        this.total = total;
        this.size = size;
        this.totalPage = getTotalPage(total, size);
    }

    public Pagination(int page, int total, int size, int totalPage) {
        this.page = page;
        this.total = total;
        this.size = size;
        this.totalPage = totalPage;
    }

}
